package com.example.bookmanager.Model;

import com.example.bookmanager.Enum.ResultCodeEnum;
import lombok.Data;

@Data
public class  Result<T> {
    public ResultCodeEnum resultCodeEnum;
    public String message;
    public T data;

    public static <T> Result<T> success(T data) {
        Result result = new Result<>();
        result.setResultCodeEnum(ResultCodeEnum.SUCCESS);
        result.setMessage("");
        result.setData(data);
        PageResult<T> pageResult = new PageResult<>();
        //pageResult.setRequestPage(result);
        return result;
    }

    public static <T> Result<T> fail(String errMsg) {
        Result result = new Result<>();
        result.setResultCodeEnum(ResultCodeEnum.FAIL);
        result.setMessage(errMsg);
        result.setData(null);
        return result;
    }

    public static <T> Result<T> nologin() {
        Result result = new Result<>();
        result.setResultCodeEnum(ResultCodeEnum.NOLOGIN);
        result.setMessage("用户未登录");
        result.setData(null);
        return result;
    }

}
